<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>获取鼠标坐标</title>
  <style>
    img {
      /* width: 80px;
            height: 90px; */
      position: absolute;
    }
  </style>
</head>

<body>
  <img src="https://tse4-mm.cn.bing.net/th/id/OIP-C.HmF-hPYpPGKb19renZV3_AHaNK?pid=ImgDet&rs=1">
  <script>
    var img = document.querySelector('img');
    document.addEventListener('mousemove', function (e) {
      var x = e.pageX;
      var y = e.pageY;
      img.style.top = y - 40 + 'px';
      img.style.left = x - 48 + 'px';
    })
  </script>
</body>

</html>